<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/***************************************************************************
 * 
 * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved
 * 
 **************************************************************************/
 
 
 
/**
 * @todo 分类控制器
 * @package controllers 
 * @file category.php
 * @author lihongliang01@baidu.com
 * @date 2015年01月04日 下午8:49:11
 * 
 *  
 **/
class Category extends MY_APP_Controller {
	
	public function index($id) {
		$catId = (int)$id;
		$this->loadModel('Post_model', 'article');
		$map = array(
			'where'=>array('is_show' => 1, 'category_id'=>(int)$catId),
			'order' => array('sorts'=>'desc','id'=>'desc'),
		);
		$this->assign['result'] = $this->getPager($this->article,$map);
		//相关文章
		$sames = $this->article->findByField(array('category_id'=>$catId), false, 5);
		$this->assign['sames'] = $sames;
		//热门文章
		$hotArticles = $this->article->findByField(array('is_hot'=>1), 'sorts desc', 5);
		$this->assign['hot'] = $hotArticles;
		//分类
		if ($catId) {
			$this->loadModel('Category_model', 'category');
			$category = $this->category->findByPk($catId);
			$this->assign['category'] = $category ? $category[0] : null;
		}
		$this->display();
	}
	
}

/*End of file category.php*/
/*Location category.php */